package com.example.database.dao;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import com.example.database.entity.UserEntity;

import java.util.List;

import io.reactivex.Flowable;

@Dao
public interface UserDao {

    @Insert
    void insertUser(UserEntity userEntity); //注册 添加一个用户

    @Insert
    void insertAllUser(List<UserEntity> userEntities); //增加全部用户

    @Delete
    void deleteUser(UserEntity userEntity); //删除一个用户

    @Delete
    void deleteAllUser(List<UserEntity> userEntities); //删除所有用户

    @Update
    void updateUser(UserEntity userEntity); //修改用户信息

    @Query("SELECT * FROM UserEntity")
    Flowable<List<UserEntity>> getAllUser();

    @Query("SELECT * FROM UserEntity WHERE phoneNumber = :phoneNumber")
    UserEntity getUserByPhoneNum(String phoneNumber);
}
